package com.klhappy.houyuan.utils;

import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;

public class ConfigManager{

    private SharedPreferences mSharedPre;

    public ConfigManager(Context context){
        this.mSharedPre = PreferenceManager.getDefaultSharedPreferences(context);
    }
    
    public ConfigManager(Context context, String name) {
    	this.mSharedPre = context.getSharedPreferences(name, 0);
    }

    public String get(String key, String defValue){
        return mSharedPre.getString(key, defValue);
    }

    public boolean set(String key, String value){
        return mSharedPre.edit().putString(key, value).commit();
    }

    public int get(String key, int defValue){
        return mSharedPre.getInt(key, defValue);
    }

    public boolean set(String key, int value){
        return mSharedPre.edit().putInt(key, value).commit();
    }
    
    public long get(String key, long defValue){
    	return mSharedPre.getLong(key, defValue);
    }
    
    public boolean set(String key, long value){
    	return mSharedPre.edit().putLong(key, value).commit();
    }
    
    public boolean get(String key, boolean defValue){
    	return mSharedPre.getBoolean(key, defValue);
    }
    
    public boolean set(String key, boolean value){
    	return mSharedPre.edit().putBoolean(key, value).commit();
    }

    public boolean remove(String key){
        return mSharedPre.edit().remove(key).commit();
    }

    public boolean clear(){
        return mSharedPre.edit().clear().commit();
    }

    public boolean contains(String key){
        return mSharedPre.contains(key);
    }
}
